package cn.ac.iscas.service.paper;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.ac.iscas.bean.base.DAOSupport;
import cn.ac.iscas.bean.base.DeleteDocument;
import cn.ac.iscas.bean.paper.PaperDocument;
@Service
@Transactional
public class PaperDocumentServiceImp extends DAOSupport<PaperDocument>
		implements IPaperDocumentService {
	@Resource protected SessionFactory sessionFactory;

	/* (non-Javadoc)
	 * @see cn.ac.iscas.bean.base.DAOSupport#delete(java.lang.Object)
	 */
	@Override
	public void delete(Object entity) {
		PaperDocument doc = (PaperDocument)entity;
		DeleteDocument.deleteDocuments(doc.getUploadRealName());
		System.out.println(doc.getId());
		doc = (PaperDocument)sessionFactory.getCurrentSession().get(PaperDocument.class, doc.getId());
		sessionFactory.getCurrentSession().delete(doc);
	}
	
}
